﻿@namespace BootstrapBlazor.Components
@inherits BootstrapComponentBase

<div class="@ClassName">
    <div class="modal-content">
        @if (ShowHeader)
        {
            <div class="modal-header">
                @if (HeaderTemplate != null)
                {
                    @HeaderTemplate
                }
                else
                {
                    <h5 class="modal-title flex-fill">@Title</h5>
                }
                <div class="modal-header-buttons">
                    @if (HeaderToolbarTemplate != null)
                    {
                        @HeaderToolbarTemplate
                    }
                    @if (ShowPrintButton && ShowPrintButtonInHeader)
                    {
                        <PrintButton Color="Color.Primary" class="btn-print" Text="@PrintButtonText" />
                    }
                    @if (ShowMaximizeButton)
                    {
                        <Button Color="Color.None" class="btn-maximize" aria-label="@MaximizeAriaLabel" OnClick="@OnToggleMaximize" Icon="@MaximizeIcon"></Button>
                    }
                    @if (ShowHeaderCloseButton)
                    {
                        <Button Color="Color.None" class="btn-close" aria-label="Close" OnClickWithoutRender="@OnClickClose"></Button>
                    }
                </div>
            </div>
        }
        <CascadingValue Name="BodyContext" Value="@BodyContext" IsFixed="true">
            <CascadingValue Value="OnClickClose" IsFixed="true">
                <div class="modal-body">
                    @RenderBodyTemplate()
                </div>
                @if (ShowFooter)
                {
                    <div class="modal-footer">
                        @if (ShowCloseButton)
                        {
                            <DialogCloseButton Text="@CloseButtonText" Icon="@CloseButtonIcon" />
                        }
                        @if (ShowPrintButton && !ShowPrintButtonInHeader)
                        {
                            <PrintButton Color="Color.Primary" class="btn-print" Text="@PrintButtonText" />
                        }
                        @if (ShowSaveButton)
                        {
                            <Button Color="Color.Primary" Text="@SaveButtonText" Icon="fa-solid fa-fw fa-floppy-disk" OnClickWithoutRender="OnClickSave" />
                        }
                        @if (FooterTemplate != null)
                        {
                            @FooterTemplate
                        }
                    </div>
                }
            </CascadingValue>
        </CascadingValue>
    </div>
</div>
